<template>
  <view class="container"> </view>
</template>

<script>
import { createOrder } from "@/util/api/vip";
// import { userInfo } from "../../util/api/user";
// import { pageUrl, appId } from "@/util/api.js";
export default {
  data() {
    return {};
  },
  onLoad(query) {
    console.log(query);
    //	uni.setStorageSync('openId', res.result.openid);
    if (!uni.getStorageSync("openId")) {
      uni.showToast({
        title: "请先登录",
      });
      uni.redirectTo({
        url: "/pages/wxlogin/index",
      });
      return;
    }
    createOrder({
      domain: query.domain,
      openId: uni.getStorageSync("openId"),
      payType: query.payType,
      userId: query.userId,
    }).then((res) => {
      console.log(res);
      // 	  appId: "wxa702cd88beea7973"
      // nonceStr: "upbVBiIp1OEuH9JX"
      // packageValue: "prepay_id=wx06134345512095ffd3c727737ceb410000"
      // paySign: "F214DC069588896DC3F688F0336BE470"
      // signType: "MD5"
      // timeStamp: "1622958225"
      uni.requestPayment({
        provider: "wxpay",
        timeStamp: res.timeStamp,
        nonceStr: res.nonceStr,
        package: res.packageValue,
        signType: res.signType,
        paySign: res.paySign,
        success: function (res) {
          uni.navigateBack();
        },
        fail: function (err) {
          console.log("fail:" + JSON.stringify(err));
        },
      });
    });
  },
  methods: {},
};
</script>
